<!--
*@Author: QWP
*@Description: 资产报废申请
*@Date: 2024-07-08 09:51:28
-->
<template>
  <a-layout class="f-h-100 s-bg-white" id="test">
    <u-search-header>
      <u-form
        :model="searchF"
        :gutter="16"
        :elements="searchEl"
        class="f-w-auto">
        <a-col>
          <u-icon-button>查询</u-icon-button>
        </a-col>
        <a-col flex="1">
          <a-row justify="end">
            <a-space>
              <u-icon-button itype="add" @click="showEdit = true">新增</u-icon-button>
              <u-icon-button itype="edit" @click="showEdit = true">修改</u-icon-button>
              <u-icon-button itype="delete" @click="">删除 </u-icon-button>
            </a-space>
          </a-row>
        </a-col>
      </u-form>
    </u-search-header>
    <a-layout-content class="f-padding-rl24">
      <u-table
        :columns="columns"
        :data="tabData"
        v-model:pagination="pagenation"></u-table>
    </a-layout-content>
  </a-layout>

  <!-- 编辑弹窗 -->
  <Edit v-model:open="showEdit"
    wrap-class-name="full-modal"
    :title="dialogTitle" />
  
  <!-- 导入 -->
  <u-imp-data v-model:open="showImp"></u-imp-data>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, watch } from "vue";
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave} from "vue-router";
import { _IFormEl } from "@/components/common/form/interface";
import { ColProps, FormItemProps, TableColumnProps } from "ant-design-vue";
import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { numberC } from '@/util/common'
import { formatAmt, } from '@/util/format.ts'
import dayjs from "dayjs";
import Edit from './Edit.vue'
import { cloneDeep } from 'lodash'
import { statusA } from '@/common/model/base'
const route = useRoute();
const router = useRouter();

onMounted(() => {
  initCols();
})

let pagenation = reactive({
  total: 0,
  current: 1,
  pageSize: 50,
  showTotal: total => `共 ${total} 条`
})
const searchF = reactive({
  model: {
    fwzh: "",
    fwzh1: "",
  },
});
const formItemProps: FormItemProps = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};
const searchEl: Array<_IFormEl> = [
  { label: "数据状态", key: "status", element: "select", col: { span: 4 }, formItemProps: formItemProps,
    componentProps: { options: statusA() }
  },
  { label: "关键字", key: "option", element: "input", col: { span: 4 }, formItemProps: formItemProps, },
];

// 列表
const tabData = reactive([
  { sfqr: '否', b2: '马权', sqbm: '应急部门', sqr: '丁艳玲', b4: dayjs().format("YYYY-MM-DD HH:MM:ss"), 
    bfzc: '保障车辆', bfsm: '无法启动', wxry: '杨鑫', b7: '待审核'
  },
  { b2: '马权', sqbm: '应急部门', sqr: '丁艳玲', b4: dayjs().format("YYYY-MM-DD HH:MM:ss"), 
    bfzc: '救援设备', bfsm: '液压装置故障', wxry: '杨鑫', b7: '待审核'
  },
]);
let columns: Array<TableColumnProps> = reactive([
  { dataIndex: "sfqr", title: "是否确认", width: 150 },
  { dataIndex: "b2", title: "经办人", width: 150 },
  { dataIndex: "sqbm", title: "申请部门", width: 150 },
  { dataIndex: "sqr", title: "申请人", width: 150 },
  { dataIndex: "b4", title: "申请日期", width: 150 },
  { dataIndex: "bfzc", title: "报废资产", width: 150 },
  { dataIndex: "bfsm", title: "报废说明", minWidth: 150 },
  { dataIndex: "b7", title: "数据状态", width: 150, fixed: 'right' },
]);

// 初始化列表表头
const initCols = () => {
  return
  let tCols = cloneDeep(originCols)
  if(['DocDraft', 'DocRed'].includes(route.name)) {
    tCols = tCols.filter(item => item.dataIndex != 'status')
  }
  columns.splice(0, columns.length, ...tCols)
}

// 编辑
let dialogTitle = ref<string>("资产报废申请")
let showEdit = ref<boolean>(false)

// 导入
let showImp = ref<boolean>(false)

</script>

<style lang="scss" scoped>
.icons-list :deep(.anticon) {
  margin-right: 6px;
  font-size: 24px;
}
</style>
